using System;
using MetaObjects.Contracts;

namespace MetaObjects.Core
{
	public abstract class MetaFieldProvider<TMetaField> : IMetaFieldProvider<TMetaField>
	{
		public Func<TMetaField, IMetaField> FieldFactory { get; set; }

		Func<object, IMetaField> IMetaFieldProvider.FieldFactory
		{
			get { return f => FieldFactory((TMetaField)f); }
		}

		public MetaFieldProvider()
		{
			FieldFactory = GetMetaField;
		}

		protected abstract IMetaField GetMetaField(TMetaField field);
	}
}